<template>
  <div>
    <!--    面包屑导航栏-->
    <el-breadcrumb separator="/">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>订单管理</el-breadcrumb-item>
      <el-breadcrumb-item>订单列表</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card>
      <!--    用户列表区-->
      <el-table :data="ordersList" border highlight-current-row lazy stripe>
        <el-table-column label="#" type="index" >
        </el-table-column>
        <el-table-column label="订单编号" prop="order_number">
        </el-table-column>
        <el-table-column label="订单价格" prop="order_price">
        </el-table-column>
        <el-table-column label="是否付款" prop="order_pay">
          <template #default="scope">
            <el-tag type="danger" v-if="scope.row.order_pay === '0'">未付款</el-tag>
            <el-tag type="success" v-else>已付款</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="是否发货" prop="is_send">
        </el-table-column>
        <el-table-column label="下单时间" prop="create_time">
        </el-table-column>
        <el-table-column label="操作" prop="mg_state">
          <template #default="scope">
            <el-button type="primary" icon="el-icon-edit" size="mini"></el-button>
            <el-button type="danger" icon="el-icon-delete" size="mini"></el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
    <el-pagination   :current-page="OrderParams.pagenum"  :page-size="OrderParams.pagesize"
                     :page-sizes="[2, 5, 8, 10]" :total="total" layout="total, sizes, prev, pager, next, jumper"
                    @size-change="handleSizeChange" @current-change="handleCurrentChange">
    </el-pagination>
  </div>
</template>

<script>
import {request} from "../../network/axios";

export default {
  name: "orders",
  created() {
    this.getOrderData()

  },
  data(){
    return{
        OrderParams:{
          pagenum:1,
          pagesize:7
        },
      total:20,
      ordersList:[]
    }
  },
  methods:{
    getOrderData(){
      request({
        url:`orders`,
        method:'get',
        params:this.OrderParams
      }).then(res=>{
        console.log(res);
        this.ordersList = res.data.data.goods
        this.total = res.data.data.total
      })
    },
    handleSizeChange(newSize){
      this.OrderParams.pagesize = newSize
      this.getOrderData()
    },
    handleCurrentChange(newPage){
      this.OrderParams.pagenum = newPage
      this.getOrderData()
    }
  }
}
</script>

<style scoped src="../../assets/css/orders/orders.css">

</style>